// xxx.js
import prompt from '@system.prompt';
export default{
    data:{
        animation:'',
        data:[1,2,3,4]
    },
    onInit(){
    },
    onShow(){
        var options = {
            duration: 1500,
            easing: 'friction',
            delay: 500,
            fill: 'forwards',
            iterations: 2,
            direction: 'normal',
        };
        var frames = [
            {transform: {translate: '-120px -0px'}, opacity: 0.1, offset: 0.0},
            {transform: {translate: '120px 0px'}, opacity: 1.0, offset: 1.0}
        ];
        this.animation = this.$element('idName').animate(frames, options);
        // handle finish event
        this.animation.onfinish = function(){
            prompt.showToast({
                message: "The animation is finished."
            });
        };
        // handle cancel event
        this.animation.oncancel = function(){
            prompt.showToast({
                message: "The animation is canceled."
            });
        };
        // handle repeat event
        this.animation.onrepeat = function(){
            prompt.showToast({
                message: "The animation is repeated."
            });
        };
    },
    start(){
        this.animation.play();
    },
    cancel(){
        this.animation.cancel();
    }
}